<template>
  <div class="music-list">
    <!-- 每一项歌曲 -->

    <div class="music-item"
      v-for="(song,index) in newSongs"
      :key="index"
      @click="getCurrentMucId(song)"
      >
      <div class="music-left">
        <div v-if="showNum"
          :class="['songsNum',{red:index<3}]">{{index+1}}
          </div>
        <div class="musicNum">
          <h3>{{song.name}}</h3>
          <span :class="{'icon':song.song.privilege.maxbr ===999000 }"><b v-for="(artists,index) in song.song.artists"
              :key="index">{{artists.name}} {{index | filterCode(song.song.artists.length)}} </b> {{song.song.album.name|filterName}}</span>
        </div>
      </div>
      <div class="music-right">
        <van-icon class="right-icon"
          name="play-circle-o"
          size="20"
          color="#aaaaaa" />
      </div>
    </div>
  </div>
</template>

<script>

export default {
  props: {
    // 存放的音乐
    newSongs: {
      type: Array

    },
    // 控制前三位数字状态
    showNum: {
      type: Boolean,
      default: false
    }
  },
  components: {

  },
  filters: {
    filterCode (val, num) {
      return val < num - 1 ? '/' : ''
    },
    filterName (value) {
      if (value) {
        return '-' + value
      } else {

      }
    }
  },
  methods: {

    // 获取当前音乐对象的id
    getCurrentMucId (e) {
      console.log(e)
      console.log(this.newSongs)
      // this.getCurrentMucId(id)
      this.$emit('play', e)
    }
  }

}

</script>

<style lang="less" scoped>
  .music-list{
     .music-item {
    display: flex;
    justify-content: space-between;
    align-content: center;
    border-bottom: 1px solid rgba(204, 204, 204, 0.904);
    padding: 3px 10px;
    .music-left {
      display: flex;
      position: relative;

    .songsNum{
     display: flex;
    // width: 40px;
    font-size: 17px;
    color: #999;
    margin-right: 10px;
    justify-content: center;
    align-items: center;
      }
      .red{
        color: #d66a50;
      }
      .musicNum{
        display: flex;
        flex-direction: column;
        justify-content: center;
      }
      h3 {
        font-size: 16px;
         overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
         -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
      }

      span {
        display: inline-block;
        color: #a6a7d0;
        font-size: 13px;
         overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
         -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        position: relative;

        &.icon {
        padding-left: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
         -webkit-line-clamp: 0;
        -webkit-box-orient: vertical;
          &::before {
            content: '';
            position: absolute;
            background: url('~@/assets/SQ.png');
            width: 12px;
            height: 8px;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            background-size: 166px 97px;

          }
        }

      }
    }

    .music-right {

      display: flex;
      flex-direction: column;
      justify-content: center;
    }
  }
  }

</style>
